import fetch from 'common/src/utils/fetch';
// 获取列表
export function getCrossResultTypeList(data) {
    return fetch({
        url: '/api/majorservice/crossResultType/queryByPage',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 获取详情
export function getCrossResultTypeDetail(gradeId, collegeId, volunteerMajorId, volunteerSubjectId) {
    return fetch({
        url: '/api/majorservice/crossResultType/detail',
        method: 'post',
        params: {
            gradeId: gradeId,
            collegeId: collegeId,
            volunteerMajorId: volunteerMajorId,
            volunteerSubjectId: volunteerSubjectId
        },
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
// 添加
export function addCrossResultType(data = []) {
    return fetch({
        url: '/api/majorservice/crossResultType/insert',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}

export function getSubject(college, gradeId) {
  return fetch({
                 url: `/api/majorservice/common/subject?college=${college}&gradeId=${gradeId}`,
                 method: 'get',
                 showMask: false
               });
}

export function getMajor(subjectId, gradeId) {
  return fetch({
                 url: `/api/majorservice/common/major?subjectId=${subjectId}&gradeId=${gradeId}`,
                 method: 'get',
                 showMask: false
               });
}

export function getCollege(authId) {
  return fetch({
                 url: `/api/majorservice/common/college?authId=${authId}`,
                 method: 'get',
                 showMask: false
               });
}

// 修改
export function updateCrossResultType(data = []) {
    return fetch({
        url: '/api/majorservice/crossResultType/update',
        method: 'put',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 软删除
export function deleteCrossResultType(data) {
    return fetch({
        url: '/api/majorservice/crossResultType/delete',
        method: 'delete',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 联动根据年级查询大类
export function getMajorByGrade(data) {
    return fetch({
        url: '/api/welcomeservice/tutorSchool/major/' + data,
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}
// 联动根据年级大类查询专业
export function getSubjectByGradeAndMajor(gradeId, majorCode) {
    return fetch({
        url: 'api/commonservice/campusProfession/findProfessionByBigProfession?grade=' + gradeId + '&bigProfessionCode=' + majorCode,
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        },
    });
}
// 联动根据大类查询学院
export function queryCollegeByMajorCode(volunteerMajorId = '', gradeId = '') {
    return fetch({
        url: 'api/majorservice/crossResultType/queryCollegeByMajorCode?volunteerMajorId=' + volunteerMajorId + '&gradeId=' + gradeId,
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
// 录取确认查批次和时间段
export function getConfirmBatch(data = {}) {
    return fetch({
        url: '/api/majorservice/confirmBatchManage/queryConfirmBatchManageByGradeId',
        method: 'post',
        data
    });
}

export function doDownload(path, fileName) {
    return fetch({
        url: `/api/commonservice/obsfile/downloadfile?objectkey=${path}`,
        method: 'get',
        responseType: "blob",
        timeout: 0
    }).then(res => {
        UTILS.downloadFile(
            res,
            fileName,
            fileName.substr(fileName.lastIndexOf(".") + 1)
        );
    });
};

export function getResultByKey(key) {
    return fetch({
        url: `/api/textbookservice/teachingTextbook/getExportResult/${key}`,
        method: 'get',
        showMask: false
    })
}